//
//  HZDispichSelectHeaderView.m
//  app
//
//  Created by 刘华舟 on 15/8/24.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZDispichSelectHeaderView.h"
#import "HZGoodsCuxiaoCellView.h"

@interface HZDispichSelectHeaderView()

@property (strong, nonatomic) HZGoodsCuxiaoCellView* dispichView;
@property (strong, nonatomic) HZGoodsCuxiaoCellView* pickupView;

@end

@implementation HZDispichSelectHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.frame = CGRectOf([UBO_WINDOW fx:UB_LEFT fy:UB_TOP],
                              [UBO_WINDOW fw:UB_WIDTH oh:kHZDispichSelectHeaderItemHeight]);
        
        self.backgroundColor = HZ_WHITE_COLOR;
                              
        _pickup = NO;
        
        _dispichView = [[HZGoodsCuxiaoCellView alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT ux:kSizeMallViewMargin fy:UB_TOP],
                                                                             [self.ubo fw:UB_WIDTH uw:-2*kSizeMallViewMargin fh:UB_HEIGHT])];
        _dispichView.tag = 1001;
        _dispichView.itemSelectTaretCaller = [UBTargetCaller of:self action:@selector(dispichWayOnChange:)];
        _dispichView.selectBtn.selected = YES;
        _dispichView.titleLabel.text = @"商家派送";
        [self addSubview:_dispichView];
        
        _pickupView = [[HZGoodsCuxiaoCellView alloc] initWithFrame:CGRectOf([_dispichView.ubo fx:UB_LEFT ux:kSizeMallViewMargin fy:UB_BOTTOM], [self.ubo fw:UB_WIDTH uw:-2*kSizeMallViewMargin fh:UB_HEIGHT])];
        _pickupView.tag = 1002;
        _pickupView.itemSelectTaretCaller = [UBTargetCaller of:self action:@selector(dispichWayOnChange:)];
        _pickupView.titleLabel.text = @"仓库自提()";
        _pickupView.hidden = YES;
        [self addSubview:_pickupView];
        
        
    }
    return self;
}


- (void)showPickupMessage:(NSString *)pickupMsg{
    self.frame = CGRectOf([UBO_WINDOW fx:UB_LEFT fy:UB_TOP],
                          [UBO_WINDOW fw:UB_WIDTH oh:2*kHZDispichSelectHeaderItemHeight]);
    _pickupView.hidden = NO;
    
    _pickupView.titleLabel.text = [NSString stringWithFormat:@"仓库自提(%@)", pickupMsg];
}

- (void)dispichWayOnChange:(HZGoodsCuxiaoCellView *)cellView{
    if (cellView.tag == 1001) {
        _pickup = NO;
        _dispichView.selectBtn.selected = YES;
        _pickupView.selectBtn.selected = NO;
        
    }else if(cellView.tag == 1002){
        _pickup = YES;
        _dispichView.selectBtn.selected = NO;
        _pickupView.selectBtn.selected = YES;
    }else{
        
    }
}

@end
